<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:a4j="http://richfaces.org/a4j"
	xmlns:rich="http://richfaces.org/rich">


<body>
	<ui:composition template="/template/template.xhtml">
		<ui:define name="body">										
			<h:form onkeypress="if (event.keyCode == 13) return false;">
								
				<rich:notifyMessages stayTime="5000" nonblocking="true" />														              			
				
											
					<rich:panel header="#{msg.search}" rendered="#{maintainAuditLogBean.status == 'INIT'}">
						<table>
							<tr>
								<td><h:outputText value="#{msg.search_type}" styleClass="outputText" style="font-size: 16px;" /></td>
								<td>
									<h:selectOneMenu id="search_search_type" styleClass="selectClass" 
										value="#{maintainAuditLogBean.searchType}">
										
										<f:selectItem itemLabel="#{msg.usergroup}" itemValue="0" />
										<f:selectItem itemLabel="#{msg.user}" itemValue="1" />										
										<f:selectItem itemLabel="#{msg.building}" itemValue="2" />
										<f:selectItem itemLabel="#{msg.floor}" itemValue="3" />
										<f:selectItem itemLabel="#{msg.room}" itemValue="4" />
										<f:selectItem itemLabel="#{msg.machine}" itemValue="5" />
																															
									</h:selectOneMenu>									
								</td>	
																														
							</tr>
							<tr>
								<td><h:outputText value="#{msg.from_date}" styleClass="outputText" style="font-size: 16px;" /></td>
								<td>
									<rich:calendar id="search_fromDate" value="#{maintainAuditLogBean.searchFromDate}" 										
                    					cellWidth="400px" cellHeight="40px" style="width:300px" />                
								</td>
							</tr>
							<tr>
								
								<td><h:outputText value="#{msg.to_date}" styleClass="outputText" style="font-size: 16px;" /></td>
								<td>
									<rich:calendar id="search_toDate" value="#{maintainAuditLogBean.searchToDate}" 										
                    					cellWidth="400px" cellHeight="40px" style="width:300px" />                
								</td>
							</tr>
							
							<tr>
								<td><h:outputText value="#{msg.audited_by}" styleClass="outputText" style="font-size: 16px;" /></td>
								<td>
									<h:selectOneMenu id="search_audited_name" styleClass="selectClass" 
										value="#{maintainAuditLogBean.searchAuditUserId}" >										
										<f:selectItems value="#{maintainAuditLogBean.auditUsers}" />																									
									</h:selectOneMenu>
								</td>
							</tr>							 		
							
							<tr>
								<td colspan="2" align="left">
									<a4j:commandButton styleClass="buttonClass" style="font-size: 16px;" 
										value="#{msg.search}" 
										action="#{maintainAuditLogBean.search}" 
										render="@form" />
								</td>

							</tr>
						</table>
					</rich:panel>	
					
					<rich:panel header="#{msg.search}" rendered="#{maintainAuditLogBean.status == 'SEARCH'}">
					
						<rich:extendedDataTable id="dataTable" width="100%" rows="15" frozenColumns="3"
							value="#{maintainAuditLogBean.auditEntities}" var="auditEntity" iterationStatusVar="it">
							
							<f:facet name="header">
				                <h:outputText value="#{msg.Maintain_audit_log}" />
				            </f:facet>
					
							<rich:column width="33px">
								<f:facet name="header">
					                <h:outputText value="#{msg.index_logo}" />
					            </f:facet>						 
								<h:outputText value="#{it.index + 1}" />						
							</rich:column>
					
							<rich:column width="80px"
								sortBy="#{auditEntity.id}"
								sortOrder="#{maintainAuditLogBean.sortsOrders['auditentity_id']}">
								
								<f:facet name="header">			                
					                <h:panelGrid columns="2">
										<a4j:commandLink style="color:#FFFFFF" styleClass="tableTitle"
											value="#{msg.type}" render="@form"
											action="#{maintainAuditLogBean.sort}" execute="@this" immediate="true" > 									
											<f:param name="sortProperty" value="auditentity_id" />							
										</a4j:commandLink>
		
										<h:graphicImage library="images" name="icons/down_icon.gif"
											rendered="#{maintainAuditLogBean.sortsOrders['auditentity_id']=='descending'}" />
		
										<h:graphicImage library="images"
											name="icons/up_icon.gif.gif"
											rendered="#{maintainAuditLogBean.sortsOrders['auditentity_id']=='ascending'}" />
		
									</h:panelGrid>
					            </f:facet>		
								<h:outputText value="#{auditEntity.id}" />
							</rich:column>	
							
							<rich:column width="150px"
								sortBy="#{auditEntity.timestamp}"
								sortOrder="#{maintainAuditLogBean.sortsOrders['auditentity_timestamp']}">
								
								<f:facet name="header">			                
					                <h:panelGrid columns="2">
										<a4j:commandLink style="color:#FFFFFF" styleClass="tableTitle"
											value="#{msg.type}" render="@form"
											action="#{maintainAuditLogBean.sort}" execute="@this" immediate="true" > 									
											<f:param name="sortProperty" value="auditentity_timestamp" />							
										</a4j:commandLink>
		
										<h:graphicImage library="images" name="icons/down_icon.gif"
											rendered="#{maintainAuditLogBean.sortsOrders['auditentity_timestamp']=='descending'}" />
		
										<h:graphicImage library="images"
											name="icons/up_icon.gif.gif"
											rendered="#{maintainAuditLogBean.sortsOrders['auditentity_timestamp']=='ascending'}" />
		
									</h:panelGrid>
					            </f:facet>		
								<h:outputText value="#{auditEntity.auditedDate}" />
							</rich:column>
							
							<rich:column width="50px"
								sortBy="#{auditEntity.entityId}"
								sortOrder="#{maintainAuditLogBean.sortsOrders['auditentity_entityId']}">
								
								<f:facet name="header">			                
					                <h:panelGrid columns="2">
										<a4j:commandLink style="color:#FFFFFF" styleClass="tableTitle"
											value="#{msg.entityId}" render="@form"
											action="#{maintainAuditLogBean.sort}" execute="@this" immediate="true" > 									
											<f:param name="sortProperty" value="auditentity_entityId" />							
										</a4j:commandLink>
		
										<h:graphicImage library="images" name="icons/down_icon.gif"
											rendered="#{maintainAuditLogBean.sortsOrders['auditentity_entityId']=='descending'}" />
		
										<h:graphicImage library="images"
											name="icons/up_icon.gif.gif"
											rendered="#{maintainAuditLogBean.sortsOrders['auditentity_entityId']=='ascending'}" />
		
									</h:panelGrid>
					            </f:facet>		
								<h:outputText value="#{auditEntity.entityId}" />
							</rich:column>
							
							<rich:column width="300px"
								sortBy="#{auditEntity.classType}"
								sortOrder="#{maintainAuditLogBean.sortsOrders['auditentity_classType']}">
								
								<f:facet name="header">			                
					                <h:panelGrid columns="2">
										<a4j:commandLink style="color:#FFFFFF" styleClass="tableTitle"
											value="#{msg.classType}" render="@form"
											action="#{maintainAuditLogBean.sort}" execute="@this" immediate="true" > 									
											<f:param name="sortProperty" value="auditentity_classType" />							
										</a4j:commandLink>
		
										<h:graphicImage library="images" name="icons/down_icon.gif"
											rendered="#{maintainAuditLogBean.sortsOrders['auditentity_classType']=='descending'}" />
		
										<h:graphicImage library="images"
											name="icons/up_icon.gif.gif"
											rendered="#{maintainAuditLogBean.sortsOrders['auditentity_classType']=='ascending'}" />
		
									</h:panelGrid>
					            </f:facet>		
								<h:outputText value="#{auditEntity.classType}" />
							</rich:column>			
							
							<rich:column width="300px"
								sortBy="#{auditEntity.description}"
								sortOrder="#{maintainAuditLogBean.sortsOrders['auditentity_descriptione']}">
								
								<f:facet name="header">			                
					                <h:panelGrid columns="2">
										<a4j:commandLink style="color:#FFFFFF" styleClass="tableTitle"
											value="#{msg.description}" render="@form"
											action="#{maintainAuditLogBean.sort}" execute="@this" immediate="true" > 									
											<f:param name="sortProperty" value="auditentity_description" />							
										</a4j:commandLink>
		
										<h:graphicImage library="images" name="icons/down_icon.gif"
											rendered="#{maintainAuditLogBean.sortsOrders['auditentity_description']=='descending'}" />
		
										<h:graphicImage library="images"
											name="icons/up_icon.gif.gif"
											rendered="#{maintainAuditLogBean.sortsOrders['auditentity_description']=='ascending'}" />
		
									</h:panelGrid>
					            </f:facet>		
								<h:outputText value="#{auditEntity.description}" />
							</rich:column>							
					
		            
				            <f:facet name="footer">
				                <rich:dataScroller page="#{maintainAuditLogBean.page}" />
				            </f:facet>
							
						</rich:extendedDataTable>
						
						
						<a4j:commandButton styleClass="buttonClass" style="font-size: 16px;" 
							value="#{msg.back}" 
							action="#{maintainAuditLogBean.back}" 
							render="@form" />
								
					</rich:panel>

			</h:form>						
			    
		</ui:define>
	</ui:composition>
</body>
</html>
